package main

import (
	"github.com/gin-gonic/gin"
	"project_file_manager/service/v1"
)

func main() {
	r := gin.Default()
	r.Static("/project_file_manager/static", "static")
	r.LoadHTMLGlob("templates/*")
	groupV1 := r.Group("/api/v1/files")
	{
		//文件的物理存储
		groupV1.POST("/file", v1.UploadFile)
		groupV1.GET("/file/:id", v1.DownloadFile)
		groupV1.DELETE("/file/:id", v1.DeleteFile)
		//文件信息入库
		groupV1.POST("/fileInfo", v1.NewFileModel)
		groupV1.DELETE("/fileInfo", v1.DeleteFileModel)
		groupV1.GET("/fileInfo/*id", v1.GetFileModel) //注意规范：   ":id"不能取空值 ， "*id"可取空值
		groupV1.GET("/fileInfo", v1.GetFileModel)
		groupV1.POST("/fileInfo/update/:id", v1.UpdateFileModel)
		//显示文件的二维码 html
		groupV1.GET("qrcode/:id", v1.PageQRCode)
		//显示首页 html
		groupV1.GET("/main", v1.PageIndex)
		groupV1.GET("/", v1.PageIndex)
	}
	_ = r.Run(":9002")
}
